﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfClient
{
    /// <summary>
    /// Window2.xaml 的交互逻辑
    /// </summary>
    public partial class Window2 : Window
    {
        LinearGradientBrush brush;
        public Window2()
        {
            InitializeComponent();

            //LinearGradientBrush brush = new LinearGradientBrush(
            //    Color.FromRgb(227, 239, 243)
            //    ,Color.FromRgb(191, 219, 255)
            //    ,new Point(0, 0)
            //    //,new Point(Math.Cos(75), Math.Sin(75))
            //    , new Point(0, 1)
            //    );//Colors.Red, Colors.Blue, new Point(1, 1)
            //brush.SpreadMethod = GradientSpreadMethod.Reflect;

            LinearGradientBrush brush = new LinearGradientBrush(
                Color.FromRgb(237, 249, 243)
                , Color.FromRgb(191, 219, 255)
                //, new Point(0, 0)
                //,new Point(Math.Cos(75), Math.Sin(75))
                //, new Point(0, 1)
                ,0
                );//Colors.Red, Colors.Blue, new Point(1, 1)
            brush.MappingMode = BrushMappingMode.Absolute;

            SizeChanged += (win, args) =>
            {
                double width = this.ActualWidth - 2 * SystemParameters.ResizeFrameHorizontalBorderHeight;
                double height = this.ActualHeight - 2 * SystemParameters.ResizeFrameVerticalBorderWidth - SystemParameters.CaptionHeight;

                Point ptCenter = new Point(width / 2, height / 2);
                Vector vectDiag = new Vector(width, -height);
                Vector vectPerp = new Vector(vectDiag.Y, -vectDiag.X);

                vectPerp.Normalize();
                vectPerp *= width * height / vectDiag.Length;

                brush.StartPoint = ptCenter + vectPerp;
                brush.EndPoint = ptCenter - vectPerp;
            };



            this.Background = brush;

            this.BorderBrush = Brushes.SaddleBrown;
            //this.BorderThickness = new Thickness(25, 50, 75, 100);

        }


    }
}
